<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" template="/templates/layout.xhtml">

	<ui:define name="ptitle">平台用户管理</ui:define>
	<ui:define name="pcontent">
		<p:tabView id="tabview" >
		    <p:ajax event="tabChange" listener="#{sysUserMB.onTabChange}" update=":tabview:frm2"/>
			<p:tab id="tab1" title="新增操作用户">
				<h:form id="frm1">
					<p:growl id="msgs1" showDetail="true" />
					<p:panel id="userPanel" header="登陆用户信息" style="margin-bottom:5px"
						footer="请输入正确的帐号、密码等必要信息进行注册。">
						<h:panelGrid columns="4" cellspacing="10" style="font-size:18px;">	
							<p:outputLabel for="userno" value="登录帐号:" style="color:red;" />
							<p:inputText id="userno" placeholder="输入登录帐号"
								value="#{sysUserMB.user.userno}" onfocus="this.select();"
								required="true" requiredMessage="登录帐号必须输入"
								validatorMessage="帐号验证不过(3-16个字符)">
								<f:validateRegex pattern="^[A-Za-z0-9]{3,16}$" />
							</p:inputText>
							<p:outputLabel for="password" value="密码:" style="color:red;" />
							<p:password id="password" placeholder="输入登录密码"
								value="#{sysUserMB.user.password}" onfocus="this.select();"
								required="true" requiredMessage="密码必须输入"
								validatorMessage="密码验证不过(3-20个字符)">
								<f:validateRegex
									pattern="^[A-Za-z0-9~`!@#$%^&amp;*()_&lt;&gt;/\\{}:;,.?]{3,20}$" />
							</p:password>	
							<p:outputLabel for="username" value="昵称:" />
							<p:inputText id="username" placeholder="输入昵称"
								value="#{sysUserMB.user.username}">
							</p:inputText>
			
							<p:outputLabel for="email" value="邮箱:" style="color:red;" />
							<p:inputText id="email" placeholder="输入联系邮箱" type="email"
								value="#{sysUserMB.user.email}" onfocus="this.select();"
								required="true" requiredMessage="邮箱必须输入"
								validatorMessage="邮箱验证不过">
								<f:validateRegex
									pattern="[a-zA-Z0-9_]*[@]{1}[a-zA-Z0-9_]*[.]{1}[a-zA-Z]{2,3}" />
							</p:inputText>
	
							<p:outputLabel for="phone" value="手机号:" style="color:red;" />
							<p:inputText id="phone" placeholder="输入联系手机号码" type="tel"
								value="#{sysUserMB.user.phone}" onfocus="this.select();"
								required="true" requiredMessage="手机号必须输入"
								validatorMessage="手机号验证不过">
								<f:validateRegex pattern="1[3-8][0-9]\d{8}" />
							</p:inputText>
	
							<p:outputLabel for="weixin" value="微信号:" />
							<p:inputText id="weixin" placeholder="输入联系微信号"
								value="#{sysUserMB.user.wxno}" onfocus="this.select();"	>
							</p:inputText>
							<p:outputLabel for="address" value="联系地址" />
							<p:inputText id="address" value="#{sysUserMB.user.address}" />
							<p:outputLabel for="remark" value="备注" />
							<p:inputText id="remark" value="#{sysUserMB.user.remarks}" />
							
							<p:outputLabel for="sex" value="性别:"  />
							<p:selectOneMenu id="sex" value="#{sysUserMB.user.sex}"	>
								<f:selectItem itemLabel="性别选择" itemValue="" />
								<f:selectItem itemLabel="女" itemValue="0" />
								<f:selectItem itemLabel="男" itemValue="1" />
						    </p:selectOneMenu>	
						    
							<p:outputLabel for="age" value="年龄:" />
							<p:inputText id="age" placeholder="输入年龄" onfocus="this.select();"								
								value="#{sysUserMB.user.age}" 
								validatorMessage="年龄必须在1-100之间" >
								<f:validateLongRange minimum="1" maximum="100" />
							</p:inputText>

						</h:panelGrid>
						<h:panelGrid columns="3">
							<p:commandButton value="取消" icon="ui-icon-power"
								action="#{sysUserMB.cancelAction}" update=":tabview:frm1:msgs1">
							</p:commandButton>
							<p:commandButton value="提交" icon="ui-icon-check"
								action="#{sysUserMB.addAction}" update=":tabview:frm1:msgs1">
							</p:commandButton>

						</h:panelGrid>
	
					</p:panel>
				</h:form>			

			</p:tab>

			<p:tab id="tab2" title="用户权限管理">
				<h:form id="frm2">
					<p:growl id="msgs2" showDetail="true" />
					<p:panel id="rightsPanel" header="用户权限管理"
						style="margin-bottom:5px"
						footer="选定某个用户，选择要授予的权限，按下Ctrl键可以多选。点击授予选定权限按钮即可。">

					<h:panelGrid columns="2" cellspacing="20" >
						<h:outputText id="userno"
						value="【当前选择的工号： #{sysUserMB.userno}】" style="font-size:16px;color:blue" />
						<p:commandButton value="授予选定权限" icon="ui-icon-check"   onclick="return confirm('确定要授予选定权限？')"
						action="#{sysUserMB.authAction()}" update=":tabview:frm2:msgs2">
						</p:commandButton>
					
					<p:dataTable id="dtuser" var="row"	value="#{sysUserMB.voSysUsers}"
						selectionMode="single" selection="#{sysUserMB.selectedUser}" rowKey="#{row.id}" 
						resizableColumns="true" liveResize="true" style="margin-bottom:20px;width:360px;height:200px;"
						rows="5" paginator="true" paginatorPosition="bottom"
						rowsPerPageTemplate="5,10,15"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">					
						<f:facet name="header">用户清单信息</f:facet>
								
				        <p:ajax event="rowSelect" listener="#{sysUserMB.onUserRowSelect}" update=":tabview:frm2" />
				        <p:ajax event="rowUnselect" listener="#{sysUserMB.onUserRowUnselect}" update=":tabview:frm2:msgs2 :tabview:frm2:userno" />
															
						<p:column headerText="登录帐号">
							<h:outputText value="#{row.userno}" />
						</p:column>	
						
						<p:column headerText="用户名称">
							<h:outputText value="#{row.username}" />
						</p:column>
										
					</p:dataTable>	

					<p:dataTable id="dtuserauthority" var="urow"	value="#{sysUserMB.voUserSysAuthorities}"
						resizableColumns="true" liveResize="true" style="margin-bottom:20px;width:360px;height:200px;"
						rows="5" paginator="true" paginatorPosition="bottom"
						rowsPerPageTemplate="5,10,15"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">					
						<f:facet name="header">用户当前权限信息</f:facet>		
															
						<p:column headerText="权限ID">
							<h:outputText value="#{urow.id}" />
						</p:column>	
						
						<p:column headerText="权限名称">
							<h:outputText value="#{urow.name}" />
						</p:column>
										
					</p:dataTable>				 
 
					<p:dataTable id="dtauthority" var="arow"	value="#{sysUserMB.voSysAuthorities}"
						selectionMode="multiple" selection="#{sysUserMB.selectedSysAuthorities}" rowKey="#{arow.id}"
						resizableColumns="true" liveResize="true" style="margin-bottom:20px;width:360px;height:200px;"
						rows="5" paginator="true" paginatorPosition="bottom"
						rowsPerPageTemplate="5,10,15"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">					
						<f:facet name="header">权限信息</f:facet>	
							
				        <p:ajax event="rowSelect" listener="#{sysUserMB.onAuthRowSelect}" update=":tabview:frm2:msgs2 :tabview:frm2:dtuserauths" />
				        <p:ajax event="rowUnselect" listener="#{sysUserMB.onAuthRowUnselect}" update=":tabview:frm2:msgs2 :tabview:frm2:dtuserauths" />
															
						<p:column headerText="权限ID">
							<h:outputText value="#{arow.id}" />
						</p:column>	
						
						<p:column headerText="权限名称">
							<h:outputText value="#{arow.name}" />
						</p:column>
										
					</p:dataTable>				 
			 
					<p:dataTable id="dtuserauths" var="srow"	value="#{sysUserMB.selectedSysAuthorities}"
						resizableColumns="true" liveResize="true" style="margin-bottom:20px;width:360px;height:200px;"
						rows="5" paginator="true" paginatorPosition="bottom"
						rowsPerPageTemplate="5,10,15"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">					
						<f:facet name="header">当前用户待设置权限信息</f:facet>		
															
						<p:column headerText="权限ID">
							<h:outputText value="#{srow.id}" />
						</p:column>	
						
						<p:column headerText="权限名称">
							<h:outputText value="#{srow.name}" />
						</p:column>
										
					</p:dataTable>				 
					
					</h:panelGrid>
					
					</p:panel>
				</h:form>

			</p:tab>

		</p:tabView>
	</ui:define>
</ui:composition>

